package cn.itsource.basic.commonenum;

/** 系统错误码 **/
public enum ErrorCode {

    SYSTEM_ERROR("1001","系统内部异常"),
    PAGE_ERROR("1002","分页错误");

    //错误码
    private String code;
    //错误信息
    private String message;

    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }
    public String getMessage() {
        return message+"["+code+"]";
    }

    public static ErrorCode getByCode(String code){
        //获取ErrorCode中所有对象的数组
        ErrorCode[] errorCodes = ErrorCode.values();

        for (ErrorCode errorCode : errorCodes) {
            if(errorCode.getCode().equals(code)){
                return errorCode;
            }
        }
        return null;
    }
}